<template>
  <div id="app">
    <router-view />
    <!-- 标签栏 -->
    <van-tabbar route v-if="flag">
      <van-tabbar-item icon="wap-home-o" to="/">{{$t('home.home')}}</van-tabbar-item>
      <van-tabbar-item icon="shopping-cart-o" to="/cart">{{$t('car.title')}}</van-tabbar-item>
      <van-tabbar-item icon="manager-o" to="/mine">{{$t('mine.title')}}</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  data () {
    return {
      cart: JSON.parse(sessionStorage.getItem('cartGoods')),
      flag: true
    }
  },
  created () {
    window.document.title = '二三买菜'
  },
  watch: {
    $route: function (val) {
      if (val.path !== '/' && val.path !== '/cart' && val.path !== '/mine') {
        this.flag = false
      } else {
        this.flag = true
      }
    }
  }
}
// 禁止手机端扩大和缩小手势
window.onload = function () {
  document.addEventListener('touchstart', function (event) {
    if (event.touches.length > 1) {
      event.preventDefault()
    }
  })
  document.addEventListener('gesturestart', function (event) {
    event.preventDefault()
  })
}
</script>

<style>
#app {
  margin-bottom: 4rem;
}
</style>
